package b3.widget.basic
{
	import b3.config.*;
	import b3.model.*;
	import b3.net.*;
	import b3.util.*;
	import b3.widget.basic.*;
	import b3.widget.mail.ObjectSlot;
	
	import flash.display.*;
	import flash.events.*;
	import flash.filters.*;
	import flash.text.*;
	
	public class FectchAwardCompleteBox extends BasicWidget
	{
		public function FectchAwardCompleteBox(awards:Array)
		{
			super();
			this.anchor = ANCHOR_MIDDLE_MIDDLE;
			this.effect = EFFECT_EXPAND;
			//背景
			var TaskAccomplishBgr:Class = ResourceHelper.getInstance().getClassByName("TaskAccomplishBgr");
			addChild(new TaskAccomplishBgr());
			//标题
			var titleText:TextField = new TextField();
			titleText.selectable = false;
        	titleText.autoSize = TextFieldAutoSize.CENTER;
			titleText.defaultTextFormat = new TextFormat("微软雅黑", 18, 0x000000, true);
			titleText.filters = [new GlowFilter(0xFFFFFF, 1, 1.3, 1.3, 100, BitmapFilterQuality.HIGH)];
			titleText.text = "成功获得物品，请到包裹查看！";
			titleText.x = (this.width - titleText.width) / 2;
			titleText.y = 30;
			addChild(titleText);
			
			//附件
			var attachmentLabel:TextField = new TextField();
			attachmentLabel.selectable = false;
        	attachmentLabel.autoSize = TextFieldAutoSize.RIGHT;
			attachmentLabel.defaultTextFormat = new TextFormat(BFont.fontName, 16, 0xFFFFFF, true);
			attachmentLabel.filters = [new GlowFilter(0x00AAFF, 1, 1.3, 1.3, 100, BitmapFilterQuality.HIGH)];
			attachmentLabel.x = 170;
			attachmentLabel.y = 120;
			attachmentLabel.text = "得到物品:";
			addChild(attachmentLabel);
			//物品框
			for (var i:int = 0; i < 3; i++)
			{
				var objectSlot:ObjectSlot = new ObjectSlot();
				objectSlot.x = 140 + i * 75;
				objectSlot.y = 160;
				addChild(objectSlot);
				if (awards != null && i < awards.length)
					objectSlot.addOjbect(awards[i]);
			}
			
			//确定按钮
			var ButtonBgr:Class = ResourceHelper.getInstance().getClassByName("CloseButton1");
			var buttonOK:BasicButton = new BasicButton(ButtonBgr);
			buttonOK.x = (this.width  - buttonOK.width) / 2;
			buttonOK.y = 276;
			buttonOK.addEventListener(MouseEvent.CLICK, onButtonOKClick);
			addChild(buttonOK);
			this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
		}
		
		private function onAddedToStage(event:Event):void
		{
			BSound.getInstance().playEffect("SoundAchievementReached");
		}
		
		private function onButtonOKClick(event:MouseEvent):void
		{
			close();
		}
        
	}
}